package com.android.basiclib.base;

import android.app.Application;
import android.os.Handler;

import com.android.basiclib.receiver.ConnectivityReceiver;
import com.android.basiclib.uitls.CommUtils;
import com.android.basiclib.uitls.ThreadPoolUtils;
import com.jeremyliao.liveeventbus.LiveEventBus;


/**
 * 底层的模组依赖库都在这里初始化
 * 当前类在Application中初始化
 */
public class BaseLibCore {

    /**
     * 初始化全局工具类和图片加载引擎
     */
    public static void init(Application application, Handler handler, int mainThread) {

        //CommUtil初始化
        CommUtils.init(application, handler, mainThread);

        //初始化LiveBus
        LiveEventBus.get()
                .config()
                .supportBroadcast(application)
                .lifecycleObserverAlwaysActive(true)
                .autoClear(false);

        //初始化全局线程池
        ThreadPoolUtils.init();

    }

    /**
     * 注册网络监听
     */
    public static void registerNetworkObserver(Application application) {
        ConnectivityReceiver.registerReceiver(application);
    }

    public static void unregisterNetworkObserver(Application application) {
        ConnectivityReceiver.unregisterReceiver(application);
    }


}
